//
//  KSUInfoItem.swift
//  ANOA
//
//  Created by 邱仙凯 on 2022/4/25.
//  Copyright © 2025 aowang. All rights reserved.
//  定制的一个item 类型

import UIKit
 import Kingfisher
class KSSignItem: KSFormHItem {
 
    lazy var img1:UIImageView = {
       let v = UIImageView()
        v.image = UIImage(named:"sh_ddd")
       return v
   }()
    lazy var line1:UIView = {
       let v = UIView()
        v.backgroundColor = .lightGray
        return v
   }()
    lazy var img2:UIImageView = {
       let v = UIImageView()
        v.image = UIImage(named:"sh_ddd")
       return v
   }()
    lazy var line2:UIView = {
       let v = UIView()
        v.backgroundColor = .lightGray
        return v
   }()
    lazy var img3:UIImageView = {
       let v = UIImageView()
        v.image = UIImage(named:"sh_ddd")
       return v
   }()
    lazy var bg1:UIView = {
       let v = UIView()
        v.backgroundColor = .white
        v.layer.masksToBounds = true
        v.layer.cornerRadius = 5
       return v
   }()
    lazy var bg2:UIView = {
       let v = UIView()
        v.backgroundColor = .white
        v.layer.masksToBounds = true
        v.layer.cornerRadius = 5
       return v
   }()
    lazy var bg3:UIView = {
       let v = UIView()
        v.backgroundColor = .white
        v.layer.masksToBounds = true
        v.layer.cornerRadius = 5
       return v
   }()
    lazy var lab1:UILabel = {
       let v = UILabel()
        v.text = "抵达签到"
       return v
   }()
    var signInClosure:(()->())?
    var signOutClosure:(()->())?
    lazy var btn1:UIButton = {
       let v = UIButton()
        v.setTitle("签到", for: .normal)
        v.titleLabel?.font = UIFont.systemFont(ofSize: 16)
        v.setTitleColor(.white, for: .normal)
        v.layer.masksToBounds = true
        v.layer.cornerRadius = 5
        v.backgroundColor = Theme.ORANGE
       return v
   }()
    lazy var lab2:UILabel = {
       let v = UILabel()
        v.text = "拜访内容"
       return v
   }()
    
     lazy var contentV:UITextView_P = {
        let v = UITextView_P()
         v.delegate = self
         v.font = UIFont.systemFont(ofSize: 16)
         v.placeHolder = "输入拜访内容"
         v.plaAlignment = .left
        return v
    }()
    lazy var lab3:UILabel = {
       let v = UILabel()
        v.text = "离开签退"
       return v
   }()
    lazy var btn3:UIButton = {
       let v = UIButton()
        v.setTitle("签退", for: .normal)
        v.titleLabel?.font = UIFont.systemFont(ofSize: 16)
        v.setTitleColor(.white, for: .normal)
        v.layer.masksToBounds = true
        v.layer.cornerRadius = 5
        v.backgroundColor = .darkGray
       return v
   }()
    lazy var lab4:UILabel = {
       let v = UILabel()
       return v
   }()
     convenience init(appearance: KSFormBaseAppear? = KSFormBaseAppear()) {
        self.init(title: "", appearance: appearance,type:.sign)
         self.backgroundColor = .clear
         self.addSubview(bg1)
         self.addSubview(bg2)
         self.addSubview(bg3)
         bg1.snp.makeConstraints { make in
              make.left.equalTo(self).offset(30)
             make.right.equalTo(self)
             make.height.equalTo(50)
              make.top.equalTo(self).offset(8)
         }
        
         bg2.snp.makeConstraints { make in
              make.left.equalTo(self).offset(30)
             make.right.equalTo(self)
              make.top.equalTo(bg1.snp.bottom).offset(8)
             make.bottom.equalTo(bg3.snp.top).offset(-8)
         }
         
         bg3.snp.makeConstraints { make in
              make.left.equalTo(self).offset(30)
             make.right.equalTo(self)
             make.height.equalTo(50)
             make.bottom.equalTo(self).offset(-8)
         }
         self.addSubview(img1)
         self.addSubview(img2)
         self.addSubview(img3)
         self.addSubview(line1)
         self.addSubview(line2)
         img1.snp.makeConstraints { make in
              make.left.equalTo(self).offset(3)
             make.width.equalTo(20)
             make.height.equalTo(20)
             make.centerY.equalTo(bg1)
         }
         img2.snp.makeConstraints { make in
              make.left.equalTo(self).offset(3)
             make.width.equalTo(20)
             make.height.equalTo(20)
             make.top.equalTo(bg2).offset(8)
         }
         img3.snp.makeConstraints { make in
              make.left.equalTo(self).offset(3)
             make.width.equalTo(20)
             make.height.equalTo(20)
             make.centerY.equalTo(bg3)
         }
         line1.snp.makeConstraints { make in
             make.top.equalTo(img1.snp.bottom).offset(3)
             make.width.equalTo(1)
             make.bottom.equalTo(img2.snp.top).offset(-3)
             make.centerX.equalTo(img1)
         }
         line2.snp.makeConstraints { make in
             make.top.equalTo(img2.snp.bottom).offset(3)
             make.width.equalTo(1)
             make.bottom.equalTo(img3.snp.top).offset(-3)
             make.centerX.equalTo(img1)
         }
         
         
         bg1.addSubview(lab1)
         lab1.snp.makeConstraints { make in
             make.left.equalTo(bg1).offset(15)
             make.centerY.equalTo(bg1)
        }
         bg1.addSubview(btn1)
         btn1.snp.makeConstraints { make in
             make.right.equalTo(bg1).offset(-15)
             make.centerY.equalTo(bg1)
             make.width.equalTo(70)
             make.height.equalTo(30)
        }
         bg2.addSubview(lab2)
          lab2.snp.makeConstraints { make in
              make.left.equalTo(bg2).offset(15)
              make.top.equalTo(bg2).offset(10)
         }
         bg2.addSubview(contentV)
         contentV.snp.makeConstraints { make in
              make.left.equalTo(bg2).offset(15)
             make.right.equalTo(bg2).offset(-15)
             make.bottom.equalTo(bg2).offset(-15)
             make.top.equalTo(lab2.snp.bottom).offset(10)
         }
         bg3.addSubview(lab3)
          lab3.snp.makeConstraints { make in
              make.left.equalTo(bg3).offset(15)
              make.centerY.equalTo(bg3)
         }
         bg3.addSubview(btn3)
         btn3.snp.makeConstraints { make in
             make.right.equalTo(bg3).offset(-15)
             make.centerY.equalTo(bg3)
             make.width.equalTo(70)
             make.height.equalTo(30)
        }
         self.addSubview(lab4)
          lab4.snp.makeConstraints { make in
              make.left.equalTo(lab3.snp.right).offset(15)
              make.centerY.equalTo(lab3)
         }
         
         btn1.addTouchUpInSideAction { _ in
             if let clo = self.signInClosure {
                 clo()
             }
         }
         btn3.addTouchUpInSideAction { _ in
             if let clo = self.signOutClosure {
                 clo()
             }
         }
      }
 
    func setIcon(image:UIImage) {
       
 
     }
    func setContent(content:String) {
         contentV.text = content
      }
}
